﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleGUI.DetectionMethods.Simple2Cameras
{
	/// <summary>
	/// Simple2Camera entrypoint
	/// </summary>
	class Simple2Camera : IDartDetector
	{
		/// <summary>
		/// New dart detected event
		/// </summary>
		public event DartDetectionEventHandler DartDetected;

		/// <summary>
		/// The setup form
		/// </summary>
		private ControlPanel detectionForm;

		/// <summary>
		/// Has this class a interface?
		/// </summary>
		public bool hasInterface { get { return true; } }

		/// <summary>
		/// Is the interface visible?
		/// </summary>
		public bool visible { get { return detectionForm.Visible; } }

		/// <summary>
		/// Constructor
		/// </summary>
		public Simple2Camera()
		{

		}

		/// <summary>
		/// Is the detection method running?
		/// </summary>
		public bool running
		{
			get { return false; }
		}

		/// <summary>
		/// Start "detecting" darts
		/// </summary>
		public void Start()
		{
			detectionForm = new ControlPanel();
			detectionForm.DartDetected += new DartDetectionEventHandler(detectionForm_DartDetected);
			ShowInterface();
		}

		/// <summary>
		/// Dart detected! :O
		/// Call the event!
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="score"></param>
		private void detectionForm_DartDetected(object sender, int score)
		{
			if (this.DartDetected != null)
				this.DartDetected(this, score);
		}

		/// <summary>
		/// Stop detecting darts
		/// </summary>
		public void Stop()
		{
			detectionForm.StopCameras();
			detectionForm.Dispose();
		}

		/// <summary>
		/// Show the interface
		/// </summary>
		public void ShowInterface()
		{
			if (detectionForm != null)
				detectionForm.Show();
		}

		/// <summary>
		/// Hide the interface
		/// </summary>
		public void HideInterface()
		{
			if (detectionForm != null)
				detectionForm.Hide();
		}
	}
}
